/*
 * Tencent is pleased to support the open source community by making ovCompose available.
 * Copyright (C) 2025 THL A29 Limited, a Tencent company. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tencent.compose.sample.mainpage

import android.graphics.Color
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Button
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.tencent.compose.sample.data.DisplayItem
//import androidx.lifecycle.viewmodel.compose.viewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

internal actual fun platformSections(): List<DisplayItem> {
    return emptyList()
}

//@Preview
//@Composable
//fun MainScreen() {
//    // 获取 ViewModel 实例
//    val viewModel: MyViewModel = viewModel()
//
//    // 收集状�?
//    val uiState by viewModel.uiState.collectAsState()
//
//    when (uiState) {
//        UiState.Loading -> {
//            CircularProgressIndicator()
//        }
//        is UiState.Success -> {
//            LazyColumn {
//                items((uiState as UiState.Success).data.size) { index ->
//                    Text(
//                        text = (uiState as UiState.Success).data[index],
//                       )
//                }
//            }
//        }
//        is UiState.Error -> {
//            Text("erroe")
//        }
//    }
//
//    // 按钮触发加载
//    Button(
//        onClick = { viewModel.loadData() },
//    ) {
//        Text("Load Data")
//    }
//}
//
//class MyViewModel : ViewModel() {
//    private val _uiState = MutableStateFlow<UiState>(UiState.Loading)
//    val uiState: StateFlow<UiState> = _uiState
//
//    fun loadData() {
//        viewModelScope.launch {
//            _uiState.value = UiState.Loading
//            try {
//                val data = fetchDataFromNetwork()
//                _uiState.value = UiState.Success(data)
//            } catch (e: Exception) {
//                _uiState.value = UiState.Error(e.message ?: "Unknown error")
//            }
//        }
//    }
//    private suspend fun fetchDataFromNetwork(): List<String> {
//        kotlinx.coroutines.delay(2000)
//        return listOf("Item 1", "Item 2", "Item 3")
//    }
//    override fun onCleared() {
//        super.onCleared()
//        println("MyViewModel: onCleared() called")
//    }
//}
//
//sealed class UiState {
//    object Loading : UiState()
//    data class Success(val data: List<String>) : UiState()
//    data class Error(val message: String) : UiState()
//}
